<?php

namespace Modules\Admin\Http\Controllers;

use Illuminate\Support\Facades\Request;
use Modules\Admin\Service\HelpCenterService;

class HelpQuestionController extends BaseController
{
    /******************************** 帮助中心-模块 ********************************/

    /*帮助中心-模块列表*/
    public function helpcenter_model_list(){
        try {
            $arr_input = Request::input();
            $result = HelpCenterService::admin_helpcenter_model_all($arr_input);
            echo_error($result);
            return view('admin::help_question.helpcenter_model_list', $result);

        }
        catch (\Exception $exception) {
            return hello_error('失败',[],$exception->getMessage());
        }
    }

    /*帮助中心-添加模块-页面*/
    public function helpcenter_model_add_page(){
        try {
            return view('admin::help_question.helpcenter_model_add_page');
        }
        catch (\Exception $exception) {
            return hello_error('失败',[],$exception->getMessage());
        }
    }

    /*帮助中心-添加模块-操作*/
    public function helpcenter_model_add_do(){
        try {
            $arr_input = Request::input();
            shiwu_start();
            $result = HelpCenterService::admin_helpcenter_model_add_one($arr_input);
            shiwu_end($result);
            return $result;
        }
        catch (\Exception $exception) {
            return hello_error('失败',[],$exception->getMessage());
        }
    }

    /*帮助中心-编辑模块-页面*/
    public function helpcenter_model_edit_page(){
        try {
            $n_id = intval( Request::input('id'));
            $result = HelpCenterService::admin_helpcenter_model_get_one($n_id);
            echo_error($result);
            return view('admin::help_question.helpcenter_model_edit_page',$result);
        }
        catch (\Exception $exception) {
            return hello_error('失败',[],$exception->getMessage());
        }
    }

    /*帮助中心-编辑模块-操作*/
    public function helpcenter_model_edit_do(){
        try {
            $arr_input = Request::input();
            shiwu_start();
            $result = HelpCenterService::admin_helpcenter_model_edit_one($arr_input);
            shiwu_end($result);
            return $result;
        }
        catch (\Exception $exception) {
            return hello_error('失败',[],$exception->getMessage());
        }
    }

    /*帮助中心-删除模块-操作*/
    public function helpcenter_model_delete(){
        try {
            $n_id = intval( Request::input('id'));
            shiwu_start();
            $result = HelpCenterService::admin_helpcenter_model_delete_one($n_id);
            shiwu_end($result);
            return $result;
        }
        catch (\Exception $exception) {
            return hello_error('失败',[],$exception->getMessage());
        }
    }

    /******************************** 帮助中心-帮助问答 ********************************/

    /*帮助中心-帮助问答列表*/
    public function helpcenter_qaq_list(){
        try {
            $arr_input = Request::input();
            $result = HelpCenterService::admin_helpcenter_qaq_list($arr_input);
            echo_error($result);
            return view('admin::help_question.helpcenter_qaq_list', $result['data']);

        }
        catch (\Exception $exception) {
            return hello_error('失败',[],$exception->getMessage());
        }
    }

    /*帮助中心-添加帮助问答-页面*/
    public function helpcenter_qaq_add_page(){
        try {
            $result = HelpCenterService::admin_helpcenter_model_all();
            echo_error($result);

            $result['n_select_cate_id'] = 0;
            return view('admin::help_question.helpcenter_qaq_add_page',$result);
        }
        catch (\Exception $exception) {
            return hello_error('失败',[],$exception->getMessage());
        }
    }

    /*帮助中心-添加帮助问答-操作*/
    public function helpcenter_qaq_add_do(){
        try {
            $arr_input = Request::input();
            shiwu_start();
            $result = HelpCenterService::admin_helpcenter_qaq_add_one($arr_input);
            shiwu_end($result);
            return $result;
        }
        catch (\Exception $exception) {
            return hello_error('失败',[],$exception->getMessage());
        }
    }

    /*帮助中心-编辑帮助问答-页面*/
    public function helpcenter_qaq_edit_page(){
        try {
            $arr_data = [];
            $n_id = intval( Request::input('id'));
            $result = HelpCenterService::admin_helpcenter_qaq_get_one($n_id);
            echo_error($result);
            $arr_data['arr_data'] = $result['data'];

            $result = HelpCenterService::admin_helpcenter_model_all();
            echo_error($result);
            $arr_data['data'] = $result['data'];

            return view('admin::help_question.helpcenter_qaq_edit_page',$arr_data);
        }
        catch (\Exception $exception) {
            return hello_error('失败',[],$exception->getMessage());
        }
    }

    /*帮助中心-编辑帮助问答-操作*/
    public function helpcenter_qaq_edit_do(){
        try {
            $arr_input = Request::input();
            shiwu_start();
            $result = HelpCenterService::admin_helpcenter_qaq_edit_one($arr_input);
            shiwu_end($result);
            return $result;
        }
        catch (\Exception $exception) {
            return hello_error('失败',[],$exception->getMessage());
        }
    }

    /*帮助中心-删除帮助问答-操作*/
    public function helpcenter_qaq_delete(){
        try {
            $n_id = intval( Request::input('id'));
            shiwu_start();
            $result = HelpCenterService::admin_helpcenter_qaq_delete_one($n_id);
            shiwu_end($result);
            return $result;
        }
        catch (\Exception $exception) {
            return hello_error('失败',[],$exception->getMessage());
        }
    }



}
